package com.gcd.skymallorderapi.service;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.situ.model.Cart;
import com.situ.model.OrderItem;
import com.situ.utils.JsonResult;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 订单项Feign服务接口
 * 用于通过Feign调用订单项相关服务
 */
@FeignClient(name = "order-item-api")
public interface OrderItemFeignService {
    /**
     * 根据订单ID分页查询订单项
     * @param pageNo 页码，默认值为1
     * @param pageSize 每页大小，默认值为10
     * @param orderId 订单ID
     * @return 订单项分页数据
     */
    @GetMapping("/api/v1/orderItem/orderId/{orderId}")
    ResponseEntity<JsonResult<Page<OrderItem>>> findByOrderId(@RequestParam(defaultValue = "1") Integer pageNo,
                                                              @RequestParam(defaultValue = "10") Integer pageSize,
                                                              @PathVariable("orderId") Integer orderId);
    /**
     * 创建订单项
     * @param carts 购物车列表
     * @return 是否创建成功
     */
    @PostMapping("/api/v1/orderItem")
    ResponseEntity<JsonResult<Boolean>> createOrderItem(@RequestBody List<Cart> carts);

    /**
     * 创建秒杀订单项
     * @param orderItem 订单项
     * @return 是否创建成功
     */
    @PostMapping("/api/v1/orderItem/create_seckill_orderItem")
    ResponseEntity<JsonResult<Boolean>> createSeckillOrderItem(@RequestBody OrderItem orderItem);

}
